/*
 * string.cpp
 *
 *  Created on: Jan 17, 2016
 *      Author: root
 */
#include<iostream>
#include<vector>
using namespace std;

namespace dounine_string{

	vector<string> split(const string& str, const string& sep){
		vector<string> ret_;
		string tmp;
		string::size_type pos_begin = str.find_first_not_of(sep);
		string::size_type comma_pos = 0;

		while (pos_begin != string::npos){
			comma_pos = str.find(sep, pos_begin);
			if (comma_pos != string::npos){
				tmp = str.substr(pos_begin, comma_pos - pos_begin);
				pos_begin = comma_pos + sep.length();
			}else{
				tmp = str.substr(pos_begin);
				pos_begin = comma_pos;
			}

			if (!tmp.empty()){
				ret_.push_back(tmp);
				tmp.clear();
			}
		}
		return ret_;
	}

}
